package com.sscaipiao.android.activity.Base;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.sscaipiao.android.R;
import com.sscaipiao.android.activity.*;
import com.sscaipiao.android.common.Constants;

/**
 * Created by ppona_000 on 13-12-30.
 */

//包括title，scroll，bottombar UI和相关功能。
public class BaseWoDeUIActivity extends BaseActivity implements View.OnClickListener {

	protected TextView mTitleText;
	private Button mTitleArrow;
	private Button mTitleBack;
	private LinearLayout mPartMain;
	private ImageView mDaTing;
	private ImageView mHeMai;
	private ImageView mKaiJiangGongGao;
	private ImageView mWoDeCaiPiao;
	private ImageView mGengDuo;


	private onClickCallback mCallback ;
	public interface onClickCallback{
		void onBaseViewClick(View view);
	}
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.base_wo_de_ui_activity);
		mTitleText = (TextView) findViewById(R.id.title_text);
		mTitleArrow = (Button) findViewById(R.id.title_arrow);
		mTitleArrow.setOnClickListener(this);
		mPartMain = (LinearLayout) findViewById(R.id.part_main);

		mDaTing = (ImageView) findViewById(R.id.hall_imageView_dating);
		mDaTing.setOnClickListener(this);
		mHeMai = (ImageView) findViewById(R.id.hall_imageView_hemai);
		mHeMai.setOnClickListener(this);
		mKaiJiangGongGao = (ImageView) findViewById(R.id.hall_imageView_kaijiang);
		mKaiJiangGongGao.setOnClickListener(this);
		mWoDeCaiPiao = (ImageView) findViewById(R.id.hall_imageView_wode);
		mWoDeCaiPiao.setOnClickListener(this);
		mGengDuo = (ImageView) findViewById(R.id.hall_imageView_gengduo);
		mGengDuo.setOnClickListener(this);
	}
	public void addContainerMain(int container_id) {
		LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
		View layout = inflater.inflate(container_id,null);
		if (layout != null) {
			mPartMain.addView(layout);
		}
	}
	public void setTitleText(String string) {
		if (mTitleText != null) {
			mTitleText.setText(string);
		}
	}
	public void setTitleText(int id) {
		if (mTitleText != null) {
			String title = getResources().getString(id);
			setTitleText(title);
		}
	}

	public void setupUI(boolean bShowBack, boolean bShowArrow) {
		mTitleBack.setVisibility(bShowBack == true ? View.VISIBLE : View.GONE);
		mTitleArrow.setVisibility(bShowArrow == true ? View.VISIBLE : View.GONE);
	}
	@Deprecated
	public void setCallback(onClickCallback cb) {
		mCallback = cb;
	}

	@Override
	public void onClick(View v) {
		Class name = null;
		if (v.getId() == R.id.hall_imageView_dating
				|| v.getId() == R.id.hall_imageView_hemai
				|| v.getId() == R.id.hall_imageView_kaijiang
				|| v.getId() == R.id.hall_imageView_wode
				|| v.getId() == R.id.hall_imageView_gengduo) {
			switch (v.getId()) {
				case R.id.hall_imageView_dating:
					name =HallActivity.class;
					break;
				case R.id.hall_imageView_hemai:
					name =TogetherHallActivity.class;
					break;
				case R.id.hall_imageView_kaijiang:
					name =KaijiangActivity.class;
					break;
				case R.id.hall_imageView_wode:
					name =MineActivity.class;
					break;
				case R.id.hall_imageView_gengduo:
					name =MoreActivity.class;
					break;
				default:
			}
			Intent intent = new Intent(this, name);
			Bundle b = new Bundle();
			b.putSerializable(Constants.USER, user);
			intent.putExtras(b);
			startActivity(intent);
		}

	}


}